import hashlib
import os


# Time: 2020/08/09 22:01 Finish
# Author: Jamie793/Jamiexu
# Site: https://blog.jamiexu.cn
# Email: doxm@foxmail.com
# The coding api from BaiDuWenKuApi,Jamie793/Jamiexu analysis and writed

suffix = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'txt', 'pdf')


class FileUtils:
    @classmethod
    def getFiles(cls, path):
        files = os.listdir(path)
        fileLists = []
        for i in files:
            for j in suffix:
                if i.endswith(j):
                    p = os.path.join(path, i)
                    p = p.replace('\\', '/')
                    fileLists.append(p)

        return fileLists

    @classmethod
    def getFileMd5(cls, path):
        with open(path, 'rb') as f:
            file = f.read()
            f.close()
        m = hashlib.md5()
        m.update(file)
        return m.hexdigest()
